﻿﻿<div>
    <MudChart ChartType="ChartType.Bar" ChartSeries="@_series" @bind-SelectedIndex="_index" ChartLabels="@_xAxisLabels" Width="100%" Height="350px"></MudChart>
</div>
<MudText Typo="Typo.h6">Selected portion of the chart: @_index</MudText>

@code {
    private int _index = -1; //default value cannot be 0 -> first selectedindex is 0.

    private readonly List<ChartSeries<double>> _series =
    [
        new() { Name = "United States", Data = new([40, 20, 25, 27, 46, 60, 48, 80, 15]) },
        new() { Name = "Germany", Data = new([19, 24, 35, 13, 28, 15, 13, 16, 31]) },
        new() { Name = "Sweden", Data = new([8, 6, 11, 13, 4, 16, 10, 16, 18]) }
    ];

    private readonly string[] _xAxisLabels = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"];
}
